﻿@model VisaApp.Models.VisaResModel
@{  AjaxOptions ajaxOpts = new AjaxOptions
    {
        HttpMethod = "post",
        OnComplete = "completedAjaxRequestFromVisa",
        OnBegin = "show_Loading",
    };
}

<script type="text/javascript">

    function completedAjaxRequestFromVisa(obj) {

        $('#box-busy').fadeOut('medium', function () {
            $('.black_overlay').css('display', 'none');
        });
        var returnObj = eval('(' + obj.responseText + ')');

        if (returnObj.Status == "success") {
            var nameQuocGia = $("#visadencacnuoc").val();
            $(".messageInfoSuccess").html("");
            var stringMess = "<div><h4>Yêu cầu tư vần Visa về nước " + nameQuocGia + "của bạn đã được tiếp nhận </h4><div></br>";
            stringMess += "<div>Chúng tôi sẽ liên hệ với bạn sơm nhất qua Email hoặc Số điện thoại mà bạn đã đăng ký tư vấn với chúng tôi </div> ";
            var $highlight = $("<div>" + stringMess + "</div>");
            $highlight.addClass("messageInfoVisa");
            $highlight.prependTo(".messageInfoSuccess");

        } else {
            makeErrorHighlightFromVisa(returnObj.Message);
        }

        return false;
    }

    function makeErrorHighlightFromVisa(messageStr) {
        var $highlight = $("<div style='padding: 0.7em; margin-bottom:5px; width: inherit;'><p><span class='' style='float: left;'></span><strong>Lỗi: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".warning-area-visa");
        $highlight.delay(4000).fadeOut(500);
    }

    function makeSuccessHighlightFromVisa(messageStr) {
        var $highlight = $("<div style='padding:0.7em; margin-bottom:5px; width: inherit;'><p><span class='' style='float: left;'></span><strong>Thành công: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".warning-area-visa");
        $highlight.delay(4000).fadeOut(500);
    }

    $(document).ready(function () {
        var selectOn = false;
        var stringNuoc = "";
        var regioncodeValue = $("#regioncode").val();
        var quocgiaid = $("#quocgiaid").val();
        if (regioncodeValue != "") {
            $.getJSON("/Visa/AllQuocGiaByCateid/" + regioncodeValue,
            function (carData) {
                var select = $("#selectProduct");
                select.empty();
                $.each(carData, function (index, itemData) {
                    if (itemData.Value == quocgiaid) {
                        selectOn = true;
                        stringNuoc = itemData.Text;
                    }
                    else {
                        selectOn = false;
                    }
                    select.append($('<option/>', {
                        value: itemData.Value,
                        text: itemData.Text,
                        selected: selectOn
                    }));
                });

                if (stringNuoc != "") {
                    $("#visadencacnuoc").val(stringNuoc);
                }
                else {
                    var name = carData[0].Text;
                    $("#visadencacnuoc").val(name);
                }

            });

            $("#selectKhuVuc option").each(function () {
                if ($(this).val() == regioncodeValue) {
                    $(this).attr("selected", "selected");
                    return;
                }
            });
        }
        else {
            onSelectlistCategory();
        }

        $(".visaNoidung").keyup(function () {
            var txtID = $("#selectProduct option:selected").val()
            var txt = $(this).val();
            $.get("/News/CauhoiByQuocGiaID?Text=" + txt, function (data) {
                $(".FromListThongtinCanbiet").html("");
                $(".FromListThongtinCanbiet").html(data);
            });
        });

    });


    function onSelectlistCategory() {
        show_Loading();
        var ids = $("#selectKhuVuc").val();
        $("#regioncode").val(ids);
        $.getJSON("/Visa/AllQuocGiaByCateid/" + ids ,
            function (carData) {
                var select = $("#selectProduct");
                select.empty();
                $.each(carData, function (index, itemData) {
                    select.append($('<option/>', {
                        value: itemData.Value,
                        text: itemData.Text
                    }));
                });
                var name = carData[0].Text;
                $("#visadencacnuoc").val(name);
            });

            $.get("/News/LisstThongtinHuuich?regioncode=" + ids + "&id=" + -1 + "&page=" + 1, function(data){
                $(".FromListThongtinCanbiet").html("");
                $(".FromListThongtinCanbiet").html(data);
                $('#box-busy').fadeOut('medium', function () {
                $('.black_overlay').css('display', 'none');
            });

        });
        
    }

    function OnSelectProduct() {
        show_Loading();
        var txt = $("#selectProduct option:selected").text();
        $("#visadencacnuoc").val(txt);
        var ids = $("#selectKhuVuc").val();
        var txtID = $("#selectProduct option:selected").val()
        $.get("/News/LisstThongtinHuuich?regioncode=" + ids + "&id=" + txtID + "&page=" + 1, function (data) {
            $(".FromListThongtinCanbiet").html("");
            $(".FromListThongtinCanbiet").html(data);
            $('#box-busy').fadeOut('medium', function () {
                $('.black_overlay').css('display', 'none');
            });

        });
    }





</script>
@using (Ajax.BeginForm("FromVisa", "Visa", null, ajaxOpts, new { enctype = "multipart/form-data", name = "frm_register-visa", id = "frm_register-visa" }))
{
    <div class="folder-titleCenter">
        <div class="folder-activeleft fl">
        </div>
        <div class="folder-activevisa fl ">
            <a class="ctR-box-title" title="Tỷ giá" href="/tu-van-visa">TƯ VẤN NHANH </a>
        </div>
        <div class="folder-activeright fl">
        </div>
        <div class="subfolder fl">
        </div>
        <div class="folder-titleright fr">
        </div>
        <div class="fr" style="padding-top: 3px">
        </div>
    </div>
    <!-- home text -->
    <div class="folder-content">
        <div style="display: inline-block">
            <div class="box-middle1 box-weather fl">
                <div class="messageInfoSuccess">
                    <ul class="formreg">
                    <li class="warning-area-visa"></li>
                    @Html.HiddenFor(model => model.Id, new { id = "IdVisa" })
                    @Html.HiddenFor(model => model.quocgiaid, new { id = "quocgiaid" })
                     @Html.HiddenFor(model => model.visadencacnuoc, new { id = "visadencacnuoc" })
                      @Html.HiddenFor(model => model.regioncode, new { id = "regioncode" })
                      @Html.HiddenFor(model => model.DiaChi, new { id = "IdVisa" })
                    <li><span class="left"><label class="labelForText">Khu vực</label></span> <span class="right">
                        <select class="inputTextSearxh" id="selectKhuVuc" onchange = "onSelectlistCategory()">
                            <option value="142">Châu Á</option>
                            <option value="150">Châu Âu</option>
                            <option value="009">Châu Đại Dương</option>
                            <option value="002">Châu Phi</option>
                            <option value="019">Bắc Mỹ</option>
                            <option value="300">Nam Mỹ</option>
                        </select>
                    </span></li>
                    <li><span class="left"><label class="labelForText">Quốc gia</label></span> <span class="right">
                        <select id="selectProduct" class="inputTextSearxh" onchange="OnSelectProduct()">
                        </select>
                    </span></li>
                    <li><span class="left"><label class="labelForText">Quốc tịch</label> </span> <span class="right">
                        @Html.TextBoxFor(model => model.Quoctich, new { name = "Quoctich", value = "", @class = "inputTextSearxh", style = "width: 99%;" })
                    </span></li>
                    <li><span class="left"><label class="labelForText">Họ tên <span class="namerequired">*</span></label></span> <span class="right">
                        @Html.TextBoxFor(model => model.HoTen, new { name = "HoTen", value = "", @class = "inputTextSearxh", style = "width: 99%;" })
                    </span></li>
                    <li><span class="left"><label class="labelForText">Email <span class="namerequired">*</span></label></span> <span class="right">
                        @Html.TextBoxFor(model => model.Email, new { name = "Email", value = "", @class = "inputTextSearxh", style = "width: 99%;" })
                    </span></li>
                    <li><span class="left"><label class="labelForText">Điện thoại <span class="namerequired">*</span></label></span> <span class="right">
                        @Html.TextBoxFor(model => model.Dt, new { name = "txt_pass", value = "", @class = "inputTextSearxh", style = "width: 99%;" })
                    </span></li>
                    <li class="line"><span class="left"><label class="labelForText">Nội dung <span class="namerequired">*</span></label></span> <span class="right">
                       @Html.TextAreaFor(model => model.NoiDung, new { name = "NoiDung", @class = "inputTextSearxh", style = "width: 98.5%; height:100px;" })
                    </span></li>
                    <li class="fone_num"><span class="left"><label class="labelForText">Mã xác nhận <span class="namerequired">*</span></label></span> <span class="right">
                        @Html.Partial("_Captcha", new VisaApp.Models.Captcha())
                        @Html.Partial("_InvisibleCaptcha", new VisaApp.Models.InvisibleCaptcha())
                    </span></li>
                    <li class="line"><span class="left">
                        <div class="btn" id="bt_search_home_flight" title="SEARCH FLIGHT">
                            <div style="position: relative; left: 5px;">
                                <input type="submit" value="GỞI TƯ VẤN" class="uppercase borderZero " tabindex="15">
                                <div class="icon_search">
                                </div>
                            </div>
                        </div>
                         @*<span class="right">
                            <br />
                            <span class="namerequired">Dấu * là thông tin bắt buộc nhập</span>
                        </span>*@
                    </li>
                </ul>
                </div>
            </div>
        </div>
    </div>
    <!-- end home text -->
    <div class="folder-bottom">
    </div>
}